package com.yj.lcj.respones;



public class Result<T> {

    public T data;
    public int code;
    public String msg;

    public String token;


    public Result(){

    }

    /**
     * 返回成功的消息
     * @return
     */
    public  Result success(String msg, int code, T data){
        Result result = new Result();
        result.msg = msg;
        result.code = code;
        result.data = data;
        return result;
    }

    /**
     * 返回成功的消息 不带数据
     * @return
     */
    public Result ok(String msg, int code){
        Result result = new Result();
        result.msg = msg;
        result.code = code;
        return result;
    }

    /**
     * 返回成功信息 带有token的消息  用于登陆的时候
     * @param msg
     * @param code
     * @param data
     * @param token
     * @return
     */
    public Result okTokenSuccess(String msg, int code, T data,String token){
        Result result = new Result();
        result.msg = msg;
        result.code = code;
        result.data = data;
        result.token = token;
        return result;
    }

    /**
     * 失败
     * @param msg 消息
     * @param code 状态码
     * @return
     */
    public static Result error(String msg,int code){
        Result result = new Result();
        result.msg = msg;
        result.code = code;
        return result;
    }
}
